import React from 'react'
import { connect } from 'react-redux'
import { projectConfig as duck } from 'ducks'
import Bool from './bool'
import Enum from './enum'
import NumberType from './number'
import StringType from './string'

const SwitchType = ({ type }) => {
  let Comp
  switch (type) {
    case 'string':
      Comp = StringType
      break
    case 'enum':
      Comp = Enum
      break
    case 'number':
      Comp = NumberType
      break
    case 'bool':
      Comp = Bool
      break
    default:
      Comp = StringType
      break
  }
  return <Comp />
}

const mapStateToProps = state => ({
  type: duck.selectors.newTagType(state),
})

export default connect(mapStateToProps)(SwitchType)
